/*
	This file is part of the JKTest
    Copyright (C) 2008 Royce Y. Feng <ryfeng@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License version 3
    as published by the Free Software Foundation. You may not use, modify
    or distribute this program under any other version of the
    GNU Affero General Public License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package GUIExtras;

import javax.swing.JMenuBar;
import javax.swing.KeyStroke;
import java.awt.event.KeyEvent;
import java.awt.event.InputEvent;

import jktest.JKMainGui;

/**
 *
 * MenuBar class that contains all the elements used for JKTest's menu bar.
 * 
 * @author Royce Feng
 */

public class MainMenuBar extends JMenuBar {

    private JKMainGui parent;
    private JKMenu file;
    private JKMenu tests;
    private JKMenu help;
    
    /**
     * 
     * Main Constructor for MainMenuBar.
     * 
     * @param _parent
     */
    public MainMenuBar( JKMainGui _parent ) {
        super();
        parent = _parent;
        file = new JKMenu("File");
        tests = new JKMenu("Tests");
        help = new JKMenu("Help");
        this.add(file);
        this.add(tests);
        this.add(help);
        JKMenuItem save = new JKMenuItem(this,"Save Results");
        file.add(save);
        save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
        JKMenuItem restart = new JKMenuItem(this,"Restart JKTest");
        file.add( restart );
        restart.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_MASK));
        JKMenuItem ao = new JKMenuItem(this,"Advanced Options");
        ao.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
        file.add( ao );
        JKMenuItem ctui = new JKMenuItem(this,"Change Theme/UI");
        ctui.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0));
        file.add( ctui );
        JKMenuItem exit = new JKMenuItem(this,"Abruptly Exit");
        //exit.setMnemonic(KeyEvent.VK_Q);
        exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_MASK));
        file.add( exit );
        tests.add( new JKMenuItem(this,"Devices") );
        tests.add( new JKMenuItem(this,"Ethernet") );
        tests.add( new JKMenuItem(this,"Floppy") );
        tests.add( new JKMenuItem(this,"Partitions") );
        tests.add( new JKMenuItem(this,"Software") );
        tests.add( new JKMenuItem(this,"Sound") );
        tests.addSeparator();
        JKMenuItem automate = new JKMenuItem(this,"Run all Automated Tests");
        automate.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
        tests.add(automate);
        JKMenuItem helpMe = new JKMenuItem(this,"About Me");
        help.add( helpMe );
        helpMe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    }
    
    /**
     * 
     * Procedure to handle MenuItem clicks
     * 
     * @param source MenuItem text
     */
    public void MenuItemClicked ( String source ) {
        parent.MenuItemClicked(source);
    }
    
}
